<?php
class lapaccountbank_model extends CI_Model
{
	// Call the module constructor
	function __construct(){
		parent::__construct();
	}
	
	function getBank()
	{
		$query = $this->db->query(" SELECT * FROM master_bank WHERE Active='1'");
		
		return $query->result();	
	}
	
	function getListAccount($bankCode,$tgl,$tgl2)
	{
		if ($bankCode != "" && $tgl != "" && $tgl2 != "")
		{
			$query = $this->db->query("SELECT A.KodeBank,A.SaldoAwal,A.Uangmasuk,A.Uangkeluar,A.SaldoAkhir,B.Bankname,B.NoRekening FROM account_mutasi_bank A,master_bank B WHERE A.KodeBank=B.KodeBank and A.Active='1' and A.KodeBank='".$bankCode."' and A.CreatedOn between '".$tgl."' and '".$tgl2."'");
		}else if (($bankCode == "") && ($tgl != "" or $tgl2 != ""))
		{
			$query = $this->db->query("SELECT A.KodeBank,A.SaldoAwal,A.Uangmasuk,A.Uangkeluar,A.SaldoAkhir,B.Bankname,B.NoRekening FROM account_mutasi_bank A,master_bank B WHERE A.KodeBank=B.KodeBank and A.Active='1' and A.CreatedOn between '".$tgl."' and '".$tgl2."'");
		}else if (($bankCode != "") && ($tgl == "" or $tgl2 == ""))
		{
			$query = $this->db->query("SELECT A.KodeBank,A.SaldoAwal,A.Uangmasuk,A.Uangkeluar,A.SaldoAkhir,B.Bankname,B.NoRekening FROM account_mutasi_bank A,master_bank B WHERE A.KodeBank=B.KodeBank and A.Active='1' and A.KodeBank='".$bankCode."'");
		}else{
			$query = $this->db->query("SELECT A.KodeBank,A.SaldoAwal,A.Uangmasuk,A.Uangkeluar,A.SaldoAkhir,B.Bankname,B.NoRekening FROM account_mutasi_bank A,master_bank B WHERE A.KodeBank=B.KodeBank and A.Active='1'");
		}
		
		return $query->result();
	}
}
?>